package cn.iocoder.yudao.module.crm.service.contract.listener;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.mq.redis.core.stream.AbstractRedisStreamMessageListener;
import cn.iocoder.yudao.module.bpm.event.ContractAuditBpmProcessInstanceStatusEvent;
import cn.iocoder.yudao.module.crm.service.contract.CrmContractService;
import cn.iocoder.yudao.module.crm.service.contract.CrmContractServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;

@Slf4j
@Component
public class CrmContractRedisConsumersListener extends AbstractRedisStreamMessageListener<ContractAuditBpmProcessInstanceStatusEvent> {


    @Resource
    private CrmContractService contractService;
    @Override // 监听器
    public void onMessage(ContractAuditBpmProcessInstanceStatusEvent message) {
        if (!StrUtil.equals(message.getProcessDefinitionKey(),CrmContractServiceImpl.BPM_PROCESS_DEFINITION_KEY)) {
            log.info("[onMessage][消息内容({})]", message);
            return;
        }
        contractService.updateContractAuditStatus(Long.parseLong(message.getBusinessKey()), message.getStatus());
    }

}
